<?php

/**
 *	@name Tasks
 *	@copyright : SMART - ULg (www.smart.ulg.ac.be)		
 *
**/


/**
 * Class Tasks : 
 * description
 * 
 * $Rev$ 
 * $LastChangedRevision$
 * $LastChangedBy$
 * $LastChangedDate$
 * $HeadURL$
 *
 * @name ProjectsListBroker
 * @package webservices/broker
 * @author : JPh HUMBLET
 * @copyright : SMART - ULg (www.smart.ulg.ac.be)
 * @category : ExAMS::Core
 *
**/

class Tasks extends AbstractProjectItem
{
	
	/**
	 * findAssignment
	 * 
	 *
	 * @return String
	 * @author jph (jp.humblet@ulg.ac.be)
	**/
	public function findAssignments($a, $r) {
		$rName = "";
		foreach ($a->Assignment as $key => $assign) {
			if ((int) $this->UID == (int) $assign->TaskUID ) {
				$rItem = $r->getByID((int) $assign->ResourceUID);
				if ( $rItem ) {
					$rName .= $rItem->Name ."(". $assign->Work->iso2String() .")" . " ";
				} else {
					$rName .= "?? ";
				}
			}
		}
		return $rName;
	}
	
	/**
	 * getByName
	 * undocumented function
	 *
	 * @return ProjectItem
	 * @author jph (jp.humblet@ulg.ac.be)
	**/
	public function getByName($name) {
		foreach ($this->children() as $child) {
			if ((string) $child->Name == $name) {
				return $child;
			}
		}
		return false;
	}
	
	/**
	 * getByAssignment
	 * undocumented function
	 *
	 * @return ProjectItem
	 * @author jph (jp.humblet@ulg.ac.be)
	**/
	public function getByAssignment($aid) {
		foreach ($this->children() as $child) {
			if ((int) $child->Name == $aid) {
				return $child;
			}
		}
		return false;
	}
	
	
}


?>